package com.netrust.cmsx.admin.modules.sys.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.netrust.cmsx.admin.modules.sys.common.AStatic;
import com.netrust.cmsx.admin.modules.sys.pojo.MenuPo;
import com.netrust.cmsx.admin.modules.sys.utils.UserUtils;
import com.netrust.cmsx.core.security.shiro.session.SessionDAO;
import com.netrust.cmsx.core.service.BaseService;
import com.netrust.cmsx.entity.module.sys.Menu;
import com.netrust.cmsx.entity.module.sys.Role;

@Service
@Transactional(readOnly = true)
public class SystemService extends BaseService {
	@Autowired
	private SessionDAO sessionDao;

	/**
	 * 获取当前用户角色列表
	 * @return
	 */
	public List<Role> getRoles(){
		return UserUtils.findRoles4CurrentUser();
	}
	
	/**
	 * 获取当前用户授权菜单列表
	 * @return
	 */
	public List<Menu> getMenuList(){
		return UserUtils.findMenu4CurrentUser();
	}

	/**
	 * 获取当前用户授权菜单树
	 * @return
	 */
	public List<MenuPo> getMenuTree(){
		return UserUtils.findMenuTree4CurrentUser();
	}

	
	/**
	 * 清除当前用户缓存
	 */
	public void clearCache(){
		UserUtils.removeCache(AStatic.Cache.CACHE_AUTH_INFO);
		UserUtils.removeCache(AStatic.Cache.CACHE_ROLE_LIST);
		UserUtils.removeCache(AStatic.Cache.CACHE_User_Menu_List);
		UserUtils.removeCache(AStatic.Cache.CACHE_User_Menu_Tree);
	}
	
	public SessionDAO getSessionDao() {
		return sessionDao;
	}



}
